package com.my.yc;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

@WebServlet(name = "YouItemServlet", value = "/YouItemServlet")
public class YouItemServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        request.setCharacterEncoding("utf-8");
        response.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        final String edu = request.getParameter("edu");
        //数组型参数
        final String[] likes = request.getParameterValues("likes");

        final PrintWriter writer = response.getWriter();
        String ed = "";
        String like = "";
        if (edu.equalsIgnoreCase("1")){
            ed += "初中";
        }else if (edu.equalsIgnoreCase("2")){
            ed += "高中";
        }else if (edu.equalsIgnoreCase("3")){
            ed += "专科";
        }else if (edu.equalsIgnoreCase("4")){
            ed += "本科";
        }
        for (int i = 0; i < likes.length ; i++){
            if (likes[i].equalsIgnoreCase("a")){
                like += "唱 ";
            }else if (likes[i].equalsIgnoreCase("b")){
                like += "跳 ";
            }else if (likes[i].equalsIgnoreCase("c")){
                like += "rap ";
            }else if (likes[i].equalsIgnoreCase("d")){
                like += "篮球 ";
            }
        }
        writer.println("你的学历:" + ed);
        writer.println("<br/>");
        writer.println("你的爱好:"+ like);

    }
}
